<template>
  <!-- 添加或修改园区对话框 -->
  <el-dialog
    title="下载"
    :visible.sync="openDown"
    width="600px"
    class='download'
    append-to-body
    @close="openClose"
    center
    :closeOnClickModal="false"
  >
    <el-upload
      class="upload-demo"
      action
      :on-preview="handlePreview"
      :file-list="fileListChild"
    >
      <!-- 上传提示 -->
      <div class="el-upload__tip" slot="tip">
        <div style="color: #f56c6c">点击文件名即可下载文件</div>
      </div>
    </el-upload>
  </el-dialog>
</template>
<script>
import { downloadFile } from "@/api/smartParks/environment/opmEnvRule";

export default {
  props: {
    fileListChild: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {
        openDown:false
    };
  },

  computed: {},

  methods: {
    handlePreview(file) {
      let index = file.name.indexOf(".");
      let name = file.name.slice(0, index);
      downloadFile(file.url, name);
    },
    open() {
      this.openDown = true;
    },
    //关闭之前初始化信息
    openClose() {
      this.openDown = false;
      //父组件修改子组件的值
      this.$emit("update:changeidentityDia", false);
    },
  },
  
};
</script>
<style  lang="scss">
.download{
 .el-dialog--center .el-dialog__body{
     padding: 0 20px 20px 20px;
 }
 .el-upload__tip {
   
    margin-top: -10px;
}
}

</style>